<style>
  .fade-enter {
    opacity:0;
  }
  .fade-leave{
    opacity:1;
  }
  .fade-enter-active{
    transition:opacity .5s;
  }
  .fade-leave-active{
    opacity:0;
    transition:opacity .5s;
  }

  .slide-left-enter,
  .slide-right-leave-active {
    opacity: 0;
    -webkit-transform: translate(100%, 0);
    transform: translate(100%, 0);
  }

  .slide-left-leave-active,
  .slide-right-enter {
    opacity: 0;
    -webkit-transform: translate(-100%, 0);
    transform: translate(-100%, 0);
  }

  .slide-right-enter-active,
  .slide-right-leave-active,
  .slide-left-enter-active,
  .slide-left-leave-active {
    will-change: transform;
    transition: all .5s;
    position: absolute;
  }

  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    height: 100%;
    overflow-y: auto;
    overflow-x: initial;
    /*overflow: hidden;*/
  }
  input[readonly="readonly"], input[disabled="disabled"] {
    color: #aaa;
  }
  .cellgroup {
    background: #fff;
    margin: 6px 0;
  }
  .fir.weui-cell:before {
    border-top: none;
  }
  .rj-cell-child-tit {
    font-size: 12px;
  }
  .weui-panel__bd {
    width: 100%;
  }
  .weui-delbtn {
    color: red;
  }
  .bg {
    overflow-y: hidden;
  }
  .weui-uploader_file {
    display: inline-block;
    padding: 2px 3px;
    border: 1px solid blue;
    margin-left: 5px;
    font-size: 12px;
    margin: 2px;
  }
  .weui-uploader_file:after {
    content: '×';
    color: blue;
    margin-left: 10px;
    cursor: pointer;
  }
  .ui.search.dropdown>input.search {
    width: auto !important;
  }
  .weui-prompt-input {
    padding: 4px 6px;
    border: 1px solid #ccc;
    box-sizing: border-box;
    height: auto;
    width: 96%;
    margin-top: 10px;
    min-height: 56px;
  }
  .weui-form-preview__label {
    text-align: left !important;
    text-align-last: left !important;
  }
</style>
<template>
  <div id="app">
<!--    <transition :name="routerTransition">-->
<!--      <keep-alive>-->
<!--        <router-view v-if="isRouterAlive"></router-view>-->
<!--      </keep-alive>-->
      <keep-alive v-if="isRouterAlive">
        <router-view v-if="$route.meta.keepAlive" ></router-view>
      </keep-alive>
      <router-view v-if="!$route.meta.keepAlive"></router-view>
<!--    </transition>-->
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      routerTransition: 'fade',
      sessionOpenid: '',
      isRouterAlive: true,
      show: true,
    }
  },
  provide () { return { reload: this.reload } },
  watch: {
    '$route': function(to, from) {
      if (from.path.indexOf('OperationLogs2') > -1 || to.path.indexOf('OperationLogs2') > -1) {
        this.routerTransition = 'fade';
      } else if (to.fullPath.indexOf('?') > -1 || from.fullPath.indexOf('?') > -1) {
        const toDepth = to.fullPath.length;
        const fromDepth = from.fullPath.length;
        this.routerTransition = toDepth < fromDepth ? 'slide-right' : 'slide-left'
      } else {
        this.routerTransition = 'fade';
      }
      //this.checkLogin();
    }
  },
  beforeCreate() {
    $.showLoading("再等等...");
  },
  created() {
  },
  beforeMount() {
  },
  mounted() {
    console.log('$route.meta:', !this.$route.meta.keepAlive)
    //关闭提交状态
    $.hideLoading();
    //新流程获取用户信息
    // this.axios({
    //   method: 'get',
    //   url: '/prod-api/getUserInfo'
    // }).then(response => {
    //   if (response.data.code == 200) {
    //     this.resetSetItem('userName', response.data.data.userName);
    //     this.resetSetItem('userId', response.data.data.userId);
    //     this.resetSetItem('userType', response.data.data.userType);
    //   } else {
    //     this.toastText('用户过期，请重新登录');
    //     setTimeout(() => {
    //       this.$router.push({name: 'signin'});
    //     }, 1000)
    //   }
    // });
  },
  methods: {
    reload () {
      this.isRouterAlive = false
      this.$nextTick(() => {
        this.isRouterAlive = true
      })
    }
  },
}
</script>
